package com.cloudsigns.factorymanager2.engineering.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.bean.ProductBean;

import java.util.ArrayList;
import java.util.List;

public class EditBatchInstallationEngineeringAdapter extends BaseAdapter {
    private Context context;
    private List<ProductBean> datas = new ArrayList<ProductBean>();
    private LayoutInflater inflater;
    private String tag = "";


    public EditBatchInstallationEngineeringAdapter(Context context, String tag) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
        this.tag = tag;
    }

    public void setData(List<ProductBean> list) {
        this.datas.clear();
        if (null != list) {
            this.datas.addAll(list);
        }

    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public ProductBean getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup viewGroup) {
        final ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = inflater.inflate(R.layout.item_edit_batch_install_engineering, null);
            holder.rl_engineering_information=convertView.findViewById(R.id.rl_engineering_information);
            holder.img_photo=convertView.findViewById(R.id.img_photo);
            holder.tv_engineering_name = convertView.findViewById(R.id.tv_engineering_name);
            holder.tv_engineering_address=convertView.findViewById(R.id.tv_engineering_address);
            holder.tv_install_cycle=convertView.findViewById(R.id.tv_install_cycle);
            holder.img_date=convertView.findViewById(R.id.img_date);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        return convertView;
    }

    private class ViewHolder {
        private RelativeLayout rl_engineering_information;
        private ImageView img_photo;
        private TextView tv_engineering_name;
        private TextView tv_engineering_address;
        private TextView tv_install_cycle;
        private ImageView img_date;
    }
}
